package com.cxcy.swustlearner.controller;
import com.cxcy.swustlearner.pojo.Class;
import com.cxcy.swustlearner.pojo.StaticUser;
import com.cxcy.swustlearner.service.ClassService;
import common.ConstStatus;
import common.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/class")
public class ClassController {
    @Autowired
    private ClassService classService;
    @GetMapping()
    public Result classController() {
        Result result = new Result();
        if(StaticUser.permission>=1){
            return Result.success(classService.getClasses());
        }
            return Result.fail("权限不足");
    }
    @PostMapping()
    public Result addClass(@RequestBody Class c) {
        Result result = new Result();
        if(StaticUser.permission>=2){
            classService.addClasses(c);
        }
            return Result.fail(ConstStatus.PERMISSION_DISABLED);
    }
}